#include "ReadConfig.h"
#include <iostream>
#include <fstream>
using namespace std;

ReadConfig::ReadConfig(const string &filename){
    ifstream ifs(filename);
    if(!ifs){
        cerr << "Unable to open config file: " << filename << endl;
        return;
    }
    string line;
    while(getline(ifs, line)){
        size_t pos = line.find('=');
        if(pos != string::npos){
            string label = line.substr(0, pos);
            string info = line.substr(pos + 1);
            _map[label] = info;
        }
    }
}

string ReadConfig::parseConfig(const string &label){
    if(_map.count(label) == 0){
        cout << "Can't find this tag" << endl;
        return string();
    }
    return _map[label];
}
